import csv
import numpy
import main_activity.writefile

headers = ["姓名", "性别", "学院", "年级", "学号", "电话", "时长", "活动项目"]


def load_file(file_name):
    value = []
    with open(file_name, "r", encoding='utf-8', newline="") as f:
        f_csv = csv.reader(f)
        for row in f_csv:
            value.append(row)
        return value


def format_file(value):
    for i in range(1, len(value)):
        try:
            value[i][4] = int(float(value[i][4]))
        except:
            pass
        try:
            value[i][5] = int(float(value[i][5]))
        except:
            pass
        try:
            value[i][6] = value[i][6].rstrip("小时")
        except:
            pass
    return value


def main(file_path):
    value = load_file(file_path)
    value = format_file(value)
    main_activity.writefile.main(file_path, value)
